package com.longrise.android.util;




import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.text.TextUtils;


public class NetBroadcastReceiver extends BroadcastReceiver {
	
	private OnBroadcastReceiverListener onBroadcastReceiverListener = null;
	
	public void setOnBroadcastReceiverListener(
			OnBroadcastReceiverListener onBroadcastReceiverListener) 
	{
		this.onBroadcastReceiverListener = onBroadcastReceiverListener;
	}

	@Override
	public void onReceive(Context context, Intent intent)
	{
		String action = intent.getAction();
		// 网络改变
		if (TextUtils.equals(action, ConnectivityManager.CONNECTIVITY_ACTION))
		{
			if(null != this.onBroadcastReceiverListener)
			{
				this.onBroadcastReceiverListener.onBroadcastReceiver();
			}
		}
	}
	
	public interface OnBroadcastReceiverListener
	{
		public void onBroadcastReceiver();
	}
}
